
<div style="margin: 15px;">
    <form class="layui-form">
        <input type="hidden" name="chapterId" value="">
        <input type="hidden" name="type" id="type" value="">
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-inline">
                <input type="text" name="title" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input type="number" name="sort" placeholder="请输入" autocomplete="off" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
                <!--<textarea id="editor" name="des" placeholder="请输入内容" autocomplete="off" class="layui-textarea"></textarea>-->
                <div id="editor" name="message"></div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">初始化代码</label>
            <div class="layui-input-inline">
                <!--<textarea type="text" name="content" id="starter" placeholder="请输入" autocomplete="off" class="layui-input" rows="5" style="height: auto"></textarea>-->
                <select name="content" id="default" lay-filter="csh" lay-verify="required">
                    <option value="">--请选择--</option>
                </select>
            </div>
        </div>

        <button lay-filter="edit" lay-submit style="display: none;"></button>
    </form>
</div>

<script src="../js/jquery-1.10.0.js"></script>
<script src="../js/template-native.js"></script>
<!-- 注意， 只需要引用 JS，无需引用任何 CSS ！！！-->
<script type="text/javascript" src="js/wangEditor.min.js"></script>
<script type="text/javascript">
    var E = window.wangEditor;
    var editor = new E('#editor');
    // 或者 var editor = new E( document.getElementById('#editor') )
    editor.customConfig.uploadImgServer = '/servlet/richtextImgUploadServlet?token='+JSON.parse(getCookie('user')).token;
    editor.create()
</script>
<script>
    $(document).ready(function(){
        var form = layui.form();
        //获取父章节
        var datac={
            userId : JSON.parse(getCookie('user')).id
        };
        var url1=HOST+"business.busScratchFile.getScratchFileListByUser.hsr";
        $.ajax({
            url: url1,
            type: 'POST',
            headers: {
                token: JSON.parse(getCookie('user')).token
            },
            data: JSON.stringify(datac),
            dataType: "json",
            success: function(result){
                for (var i= 0;i < result.value.length;i++){
                    $("#default").append("<option value='"+result.value[i].id+"'>"+result.value[i].name+"</option>");
                }
                form.render('select','csh');
            },
            error:function(xhr){
                alert("错误提示： " + xhr.status + " " + xhr.statusText);
            }
        });
    })
</script>